package com.example.moviepro.mapper;


import com.example.moviepro.entity.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Insert("INSERT INTO comment(movieId, content, rating) values (#{movieId}, #{content},#{rating})")
    void addComment(Comment comment);

    @Select("select * from comment where movieId = #{movieId}")
    List<Comment> getCommentsByMovieId(int movieId);



    @Select("SELECT id FROM comment ORDER BY id DESC LIMIT 1")
    int findCommentId(Comment comment);

    @Select("select * from comment where id = #{id}")
    Comment findCommentById(int id);

    @Delete("delete from comment where id = #{id}")
    void deleteComment(int id);
}
